package com.itsitio.registeradmin.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.itsitio.registeradmin.dao.PortalStatisticDao;
import com.itsitio.registeradmin.dao.base.SpringHibernateDao;
import com.itsitio.registeradmin.model.PortalStatistic;

@Repository
public class PortalStatisticDaoImpl extends SpringHibernateDao<PortalStatistic> implements
PortalStatisticDao{
	
	@Autowired
	public PortalStatisticDaoImpl(SessionFactory sessionFactory) {
		super(sessionFactory);
	}
	
	@Override
	protected Class<PortalStatistic> getObjetoManejado() {
		return PortalStatistic.class;
	}

	@Transactional(readOnly = true)
	public List<PortalStatistic> findPortalStatistic(){
		System.out.println("===== PortalStatisticDaoImpl.findPortalStatistic()");
		DetachedCriteria criteria = DetachedCriteria.forClass(PortalStatistic.class);
		List<PortalStatistic> result = getHibernateTemplate().findByCriteria(criteria);
		if (result != null )
			System.out.println("===== PortalStatisticDaoImpl.findPortalStatistic() result.size()-"+result.size());
		else
			System.out.println("===== PortalStatisticDaoImpl.findPortalStatistic() result=null");				
			
		return result;
		//return getHibernateTemplate().findByCriteria(criteria);		
		//return getHibernateTemplate().loadAll(getObjetoManejado());
			
	}

	
}
